%% Functions to plot the ratio of hat-nu and study se by group

function fig = plot_nu_asymse_ratio(EB_est_nu, rep_base_se2, rep_val_se2, size_base, size_val, yscale, xtick)

    % Combine rep_base_se2 and rep_val_se2 to form a N x (J+1) matrix
    se2 = [rep_base_se2, rep_val_se2];
    size = [size_base, size_val];
    mat = se2 .* size;
    % Convert the variances to std errors
    mat = sqrt(mat);
    
    % Compute the row averages
    row_avg = mean(mat, 2);
    
    % Compute the ratios
    ratios = sqrt(EB_est_nu) ./ row_avg;
    [sorted_ratios, ~] = sort(ratios);
    
    % Generate the plot
    fig = figure;
    set(fig, 'Units', 'inches', 'Position', [1 1 5.833 4.373]);
    plot(1:length(ratios), sorted_ratios, 'LineWidth', 2.5);
    hold on;
    ylim(yscale);

    xticks(xtick);
    xlim([xtick(1), xtick(end)]);
    xlabel('');
    ylabel('');
    title('');
    set(gca, 'FontSize', 18);
    hold off;

end